<?php
namespace App\Services;

use Illuminate\Support\Facades\Redis;

class RedisService
{
    public function decreaseStock($productId, $qty)
    {
        $script = file_get_contents(storage_path('scripts/decr_stock.lua'));

        return Redis::eval(
            $script,
            1, // key的数量
            'product_'.$productId, // KEYS[1]
            $qty // ARGV[1]
        );
    }
}
